package com.promis.party.helper;

import android.content.Context;
import android.content.res.Resources;

import com.promis.party.R;
import com.promis.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

public class ContextHelper {

	private Context context;
	private Resources resources;

	private List<String> netResRecycleList;

	public ContextHelper(Context context) {
		this.context = context;
		this.resources = context.getResources();
	}

//	public String getImgUrlByPath(String imagePath) {
//		// TODO Auto-generated method stub
//		return resources.getString(R.string.server_request_schema) + "://" +
//				resources.getString(R.string.server_request_ip) + ":" +
//				resources.getString(R.string.server_request_port) + "/" +
//				resources.getString(R.string.server_request_context) + imagePath;
//	}

//	public String getImgUrlByGridFS(String id) {
//		// TODO Auto-generated method stub
//		return resources.getString(R.string.server_request_schema) + "://" +
//				resources.getString(R.string.server_request_ip) + ":" +
//				resources.getString(R.string.server_request_port) + "/" +
//				resources.getString(R.string.server_request_context) + "/" +
//				resources.getString(R.string.server_request_mobile) + "/" +
//				resources.getString(R.string.show_image) + "/" + id;
//	}

//	public String getUrlByFastDFS(String fullPath) {
//		return resources.getString(R.string.server_nginx_fasfdfs) + fullPath;
//	}

	public String getNetResUrl(String fullPath) {
		return resources.getString(R.string.pfs_nginx_root) + fullPath;
	}

	public String getUrlByBehaviorConrrection() {
		return resources.getString(R.string.server_request_schema) + "://" +
				resources.getString(R.string.server_request_ip) + ":" +
				resources.getString(R.string.server_request_port) + "/" +
				resources.getString(R.string.server_request_context) + "/mag/img/behaviorconrrection.png";
	}

	public String getUrlByBehaviorConrrectionHome() {
		return resources.getString(R.string.server_request_schema) + "://" +
				resources.getString(R.string.server_request_ip) + ":" +
				resources.getString(R.string.server_request_port) + "/" +
				resources.getString(R.string.server_request_context) + "/mag/jsp/behaviorcorrection/mobile/behavior_correction_apply.jsp";
	}

	public String getServiceUrl(int urlResId) {
		// TODO Auto-generated method stub
		return resources.getString(R.string.server_request_schema) + "://" +
				resources.getString(R.string.server_request_ip) + ":" +
				resources.getString(R.string.server_request_port) + "/" +
				resources.getString(R.string.server_request_context) + "/" +
				resources.getString(R.string.server_request_mobile) + "/" +
				resources.getString(urlResId);
	}

	public void addNetResRecycle(String httpOriginalPath) {
		if (StringUtils.isNullOrEmpty(httpOriginalPath)) return;
		if (netResRecycleList == null) {
			netResRecycleList = new ArrayList<>();
		}
		netResRecycleList.add(httpOriginalPath);
	}

	public void removeNetResRecycle(String httpOriginalPath) {
		netResRecycleList.remove(httpOriginalPath);
	}

	public List<String> getNetResRecycleList() {
		return netResRecycleList;
	}

	public Context getContext() {
		return context;
	}
}
